// detect
#include<bits/stdc++.h>
using namespace std;


int d[100005];
int d2[100005];
int v[100005];
int a[100005];
int arr[100005];
int arr2[100005];

int main(){
	
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    //README
    
    int T,  n, m, L, V,  temp;
    int p = -1, p2 = 100005;
    int res, res2;
    
    cin>>T;
    for(int g = 1; g <= T; g++){
		res = 0;
		res2 = 0;
		for(int i = 1; i < 100005; i++){
			d[i] = 0;
			d2[i] = 0;
			v[i] = 0;
			a[i] = 0;
			arr[i] = 0;
			arr2[i] = 0;
		}
		
		cin>>n>>m>>L>>V;
		for(int i = 1; i <= n; i++){
			scanf("%d %d %d", &d[i], &v[i], &a[i]);
		}
		for(int i = 1; i <= m; i++){
			scanf("%d", &temp);
			arr[temp]++;
			arr2[i] = temp;
			if(p < temp) p = temp;
			if(p2 > temp) p2 = temp;
		}
		
		for(int i = 1; i <= n; i++){		// question1
			if(a[i] == 0){
				 if(v[i] > V) res++;
			}
			else if(a[i] < 0){
				for(int j = d[i]; ; j++){
					if(arr[j] > 0){
						int v2;
						long long t;
						long long dis;
						
						t = (-1.0)*v[i]/a[i];
						dis = 1.0*v[i]*t/2;
						if(dis > 1.0*(j-d[i])){
							v2 = 2*a[i]*(j-d[i]) + v[i]*v[i];
							if(v2 > V*V){
								res++;
							}
						}
						break;
					}
				}
			}
			else if(a[i] > 0){
				int v2;
				
				v2 = 2*a[i]*(p-d[i]) + v[i]*v[i];
				if(v2 > V*V){
					res++;
					continue;
				}
			}
		}
		sort(arr2+1, arr2+m+1);		// question2(solve a<0)
		for(int i = 1; i <= n; i++){
			if(a[i] < 0){
				d2[d[i]]++;
			}
		}
		if(d2[1] > 0) res++;
		for(int i = 2; i < m; i++){
			for(int j = arr2[i-1]+1; j <= arr2[i]; j++){
				if(d2[j] > 0){
					res2++;
					break;
				}
			}
		}
		res2++;
		
		cout<<res<<" "<<res2<<endl;
	}
	
    return 0;
}
